<?php 
$this->headLink()->prependStylesheet(_STATIC_HTTP . '/www/mobile/photo.css');
$photos = (array) $this->special['_photos'];
$index = 1;
$total = count($photos);
foreach($photos AS $key => $photo) {
	if($this->photo['id'] == $photo['id']) {
		$index = $key + 1;
		break;
	}
}
if($index == 1 || !isset($photos[$index - 2]['id'])) {
	$prevUrl = null;
} else {
	$prevUrl = (string) $this->url('special/photo', array('name' => $this->special['name'], 'id' => $photos[$index - 2]['id']));
}
if($index == $total || !isset($photos[$index]['id'])) {
	$nextUrl = null;
} else {
	$nextUrl = (string) $this->url('special/photo', array('name' => $this->special['name'], 'id' => $photos[$index]['id']));
}
$title = $this->escape($this->special['title']);

$previous = $this->special['_previous'];
$next = $this->special['_next'];
?>
<?php echo $this->render('layout/_inc/banner.phtml');?>
<h1><a href="<?php echo $this->special['_url'];?>"><?php echo $title . '<em>(' . $index . '/' . $total . ')</em>';?></a></h1>
<div class="box">
	<div class="bd npx">
		<div>
			<?php if($prevUrl) { ?>
			<a href="<?php echo $prevUrl;?>" class="previous"><?php echo $this->language('上一张');?></a> 
			<?php } ?>
			<?php if($prevUrl && $nextUrl) {?>||<?php } ?>
			<?php if($nextUrl) { ?>
			<a href="<?php echo $nextUrl;?>" class="next"><?php echo $this->language('下一张');?></a>
			<?php } ?>
		</div>
	</div>
	<div class="clear"></div>
	<div class="bd image">
		<a href="<?php
			echo ($nextUrl) ? $nextUrl : (!empty($next) ? $next['_gurl'] : $this->special['_url']);
		?>"><img src="<?php echo $this->photo['_image']['thumb'];?>" class="thumb" /></a>
	</div>
	<div class="clear"></div>
	<div class="bd np">
		<ul>
			<?php 			
			if(!empty($previous)) {
				echo '<li class="prev">';
				echo '<a href="' . $previous['_gurl'] . '">';
				echo $this->language('上一组');
				echo ': ' . $this->escape($previous['title']) . '<em class="red number">(' . $previous['ptotal'] . 'P)</em></a>';
				echo '</li>';
			}
			if(!empty($next)) {
				echo '<li class="next">';
				echo '<a href="' . $next['_gurl'] . '">';
				echo $this->language('下一组');
				echo ': ' . $this->escape($next['title']) . '<em class="red number">(' . $next['ptotal'] . 'P)</em></a>';
				echo '</li>';
			}
			?>
		</ul>
	</div>
	<div class="clear"></div>
</div>
<div class="box">
	<div class="bd">
		<?php echo $this->advertise('banner300x50')->render($this->client);?>
	</div>
</div>
<div class="box">
	<div class="hd"><h3><?php echo $this->language('相关推荐');?></h3></div>
	<div class="bd">
		<ul class="list2">
			<?php foreach($this->special['_related'] AS $key => $row) { ?>
			<li><a href="<?php echo $row['_gurl'];?>"><?php echo $this->escape($row['title']);?><em class="red number">(<?php echo $row['ptotal'];?>P)</em></a></li>
			<?php } ?>
		</ul>
	</div>
	<div class="clear"></div>
</div>